import React,{FC, useEffect, useState} from "react";
import { Link } from "react-router-dom";
import {Space,Typography} from 'antd'
import { FormOutlined } from '@ant-design/icons'
import useGetUserInfo from "../hooks/useGetUserInfo";
import styles from './Logo.module.scss'
import { HOME_PATHNAME, MANAGE_INDEX_PATHNAME } from "../router";

const {Title} =Typography

const Logo:FC=()=>{
    const {username} = useGetUserInfo()
    const [pathname,setPathname]=useState('/')
    useEffect(()=>{
        if(username){
            setPathname(MANAGE_INDEX_PATHNAME)
        }else{
            setPathname(HOME_PATHNAME)
        }

    },[username])
    return <div className={styles.container}>
        <Link to={pathname}>
            <Space>
                <Title><FormOutlined />&nbsp;星瑞问卷</Title>
            </Space>
        </Link>
       
    </div>
}
export default Logo